package com.tac.service.wms.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.wms.ReplenishmentApprovalDao;
import com.tac.pojo.wms.ReplenishmentApproval;
import com.tac.service.wms.ReplenishmentApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ReplenishmentApprovalImpl implements ReplenishmentApprovalService {

    @Autowired
    private ReplenishmentApprovalDao replenishmentApprovalDao;

    public Result<PageInfo<ReplenishmentApproval>> getList(Integer pageNum, Integer pageSize, String documentNumber, String applicant, Date applicationDateStart, Date applicationDateEnd, String applicationStatus, String reviewer,
                          Date reviewDateStart, Date reviewDateEnd, String reviewStatus){
        PageHelper.startPage(pageNum,pageSize);
        List<ReplenishmentApproval> list = replenishmentApprovalDao.getList(documentNumber, applicant, applicationDateStart, applicationDateEnd, applicationStatus, reviewer, reviewDateStart, reviewDateEnd, reviewStatus);
        PageInfo<ReplenishmentApproval> replenishmentApprovalPageInfo = new PageInfo<>(list);
        return Result.success(replenishmentApprovalPageInfo);
    }


    public Result update(ReplenishmentApproval replenishmentApproval){
        Integer integer = replenishmentApprovalDao.update(replenishmentApproval);
        if(integer>0){
            return Result.success(null);
        }
        return Result.error("修改失敗");
    }
}
